﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

namespace QFramework.Pacman
{
    public class Scores : MonoBehaviour
    {
        [Inject]
        public ScoreManager ScoreManager { get; set; }

        Text scores_txt;

        public void Awake()
        {
            PacmanGame.Container.RegisterInstance(this);
        }

        private void Start()
        {
            PacmanGame.Container.Inject(this);
        }

        public void UpdateGUIText(List<ScoreManager.Score> scoreList)
        {
            scores_txt = GetComponent<Text>();
            Debug.Log("Updating GUIText: scorelist count=" + scoreList.Count);
            string s = "";
            foreach (ScoreManager.Score sc in scoreList)
            {
                if (sc.score < 1000)
                    s += sc.score + "\t\t\t" + sc.name + "\n";
                else
                    s += sc.score + "\t\t" + sc.name + "\n";
            }

            scores_txt.text = s;
        }
    }
}